import Vue from "vue";
import Vuex from "vuex";
import persistedState from "vuex-persistedstate";

Vue.use(Vuex);

export default new Vuex.Store({
  plugins: [
    persistedState({
      reducer(val) {
        return {
          userInfo: val.userInfo,
          psdDInfo: val.psdDInfo,
        };
      },
    }),
  ],
  // 初始化vuex参数
  state: {
    userInfo: {},
    psdDInfo: {},
  },
  getters: {},
  // 对定义参数进行操作
  mutations: {
    // 保存用户信息
    saveUserInfo(state, userData) {
      state.userInfo = userData;
    },
    // 清除有用户信息
    removeUserInof(state) {
      state.userInfo = {};
    },
    // 记住密码
    savePsdInfo(state, psdData) {
      state.psdDInfo = psdData;
    },
    // 未开启记住密码
    removePsdInfo(state) {
      state.psdDInfo = {};
    },
  },
  actions: {},
  modules: {},
});
